<template>
    <div class="receipt">
      <Layout :style="{padding: '0 24px 24px'}">
        <Breadcrumb :style="{margin: '24px 0'}">
          <BreadcrumbItem><a href="javascript:void(0)" @click="jump('/index')">首页</a></BreadcrumbItem>
          <BreadcrumbItem>财务管理</BreadcrumbItem>
          <BreadcrumbItem>资金管理</BreadcrumbItem>
        </Breadcrumb>
        <Content id="tal" :style="{padding: '24px', minHeight: '280px', background: '#fff'}">
          <div class="f-header" ghost>
            <div class="f-header-search">
              <span>搜索条件：</span><br>
              <Row>
                <Col span="2" align="right">
                  <span>款单类型：</span>
                </Col>
                <Col span="5">
                  <Select v-model="category" style="width:100%" placeholder="请选择类型...">
                    <Option value="全部">全部</Option>
                    <Option value="付款单">付款单</Option>
                    <Option value="收款单">收款单</Option>
                    <Option value="其他收入单">其他收入单</Option>
                    <Option value="其他支出单">其他支出单</Option>
                    <Option value="其它应付款单">其它应付款单</Option>
                    <Option value="其它应收款单">其它应收款单</Option>
                  </Select>
                </Col>
                <Col span="2"  align="right">
                  <span>往来单位：</span>
                </Col>
                <Col span="5">
                  <Input v-model="search" placeholder="请输入往来单位名称..." style="width:100%"></Input>
                </Col>
                <Col span="2"  align="right">
                  <span>确认状态：</span>
                </Col>
                <Col span="5">
                  <Select v-model="confirmStatus" style="width:100%" placeholder="请选择款单确认状态...">
                    <Option value="全部">全部</Option>
                    <Option value="已确认">已确认</Option>
                    <Option value="未确认">未确认</Option>
                  </Select>
                </Col>
              </Row>
              <div style="height: 16px"></div>
              <Row>
                <Col span="2" align="right">
                  <span>开始时间：</span>
                </Col>
                <Col span="5">
                  <DatePicker v-model="beginTime" type="date" placeholder="请选择开始时间..." style="width:100%"></DatePicker>
                </Col>
                <Col span="2" align="right">
                  <span>结束时间：</span>
                </Col>
                <Col span="5">
                  <DatePicker v-model="endTime" type="date" placeholder="请选择结束时间..." style="width:100%"></DatePicker>
                </Col>
                <Col span="2">
                  <Button style="margin-left: 20%;margin-top: -3px" @click="toSearch"><Icon type="md-search" />搜索</Button>
                </Col>
              </Row>
            </div>
            <Button @click="addDrawer=true"><Icon type="md-add" />新增</Button>
            <Button @click="toRefresh"><Icon type="md-sync" />刷新</Button>
          </div>
          <div class="f-content" style="width: 100%;height: 72vh;overflow: hidden;margin-top: 1%">
            <div style="overflow-y:scroll;width: 101.5%;height: 100%;margin-right: -20px">
              <Table :columns="tb_columns"  :height="666" :data="receipt_list" size="small" ref="table">
                <template slot-scope="{ row }" slot="confirmationStatus">
                  <span v-if="row.confirmationStatus==='未确认'" class="status-error">未确认</span>
                  <span v-else class="status-success">已确认</span>
                </template>
              </Table>
              <Page :total="receipt_total" :current="receipt_current_page" :page-size="receipt_page_size" @on-change="onChange" @on-page-size-change="onPageSizeChange" show-total show-sizer size="small" style="float:right;margin-top:12px"/>
            </div>
          </div>
        </Content>
      </Layout>
      <Drawer title="新增款单" :closable="false" v-model="addDrawer" width="50" :mask-closable="false">
        <Form ref="addForm" :model="addForm" :rules="addRuleVal" :label-width="120">
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="类型：" prop="category">
                <Select v-model="addForm.category" style="width:100%" placeholder="请选择类型...">
                  <Option value="付款单">付款单</Option>
                  <Option value="收款单">收款单</Option>
                  <Option value="其他收入单">其他收入单</Option>
                  <Option value="其他支出单">其他支出单</Option>
                  <Option value="其它应付款单">其它应付款单</Option>
                  <Option value="其它应收款单">其它应收款单</Option>
                </Select>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="付款日期：">
                <DatePicker type="date" placeholder="请选择付款日期..." v-model="addForm.paymentDate" style="width: 100%"></DatePicker>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="发票号：" prop="receiptNumber">
                <Input v-model="addForm.receiptNumber" placeholder="发票号..."></Input>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="往来单位：" prop="transitUnit">
                <Input v-model="addForm.transitUnit" placeholder="请输入往来单位..."></Input>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="付款金额：" prop="paymentAmount">
                <Input   v-model="addForm.paymentAmount" placeholder="请输入付款金额..."></Input>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="付款方式：" prop="paymentMethod">
                <Select v-model="addForm.paymentMethod" style="width:100%" placeholder="请选择付款方式...">
                  <Option value="网上银行">网上银行</Option>
                  <Option value="现金">现金</Option>
                  <Option value="转帐支票">转帐支票</Option>
                  <Option value="现金支票">现金支票</Option>
                  <Option value="银行汇票">银行汇票</Option>
                  <Option value="电汇">电汇</Option>
                  <Option value="承兑汇票">承兑汇票</Option>
                  <Option value="现金支票">现金支票</Option>
                </Select>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="银行：">
                <Select v-model="addForm.bank" style="width:100%" placeholder="请选择银行...">
                  <Option v-for="(item,key) in bankList" :key="key" :value="item.text">{{item.text}}</Option>
                </Select>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="银行账号：">
                <Input v-model="addForm.bankAccount" :minlength="15" :maxlength="19" placeholder="请输入银行账号..."></Input>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="汇率：">
                <Input v-model="addForm.exchangeRate" placeholder="请输入汇率..."></Input>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="所属项目：" prop="belongProject">
                <Input v-model="addForm.belongProject" placeholder="请输入所属项目..."></Input>
              </FormItem>
            </Col>
          </Row>
          <Row>
            <Col span="24">
              <FormItem label="摘要：" prop="summary">
                <Input type="textarea" :row="4" v-model="addForm.summary" placeholder="请输入摘要..."></Input>
              </FormItem>
            </Col>
          </Row>
        </Form>
        <div class="demo-drawer-footer">
          <Button type="primary" @click="handleSubmit('addForm')">提交</Button>
          <Button @click="handleReset('addForm')" style="margin-left: 8px">取消</Button>
        </div>
      </Drawer>
      <Drawer title="确认款单" :closable="false" v-model="updateDrawer" width="50" :mask-closable="false">
        <Form ref="addForm" :model="addForm" :rules="addRuleVal" :label-width="120">
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="类型：" prop="category">
                <Select v-model="addForm.category" style="width:100%" placeholder="请选择类型...">
                  <Option value="付款单">付款单</Option>
                  <Option value="收款单">收款单</Option>
                  <Option value="其他收入单">其他收入单</Option>
                  <Option value="其他支出单">其他支出单</Option>
                  <Option value="其它应付款单">其它应付款单</Option>
                  <Option value="其它应收款单">其它应收款单</Option>
                </Select>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="付款日期：">
                <DatePicker type="date" placeholder="请选择付款日期..." v-model="addForm.paymentDate" style="width: 100%"></DatePicker>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="发票号：" prop="receiptNumber">
                <Input v-model="addForm.receiptNumber" placeholder="发票号..."></Input>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="往来单位：" prop="transitUnit">
                <Input v-model="addForm.transitUnit" placeholder="请输入往来单位..."></Input>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="付款金额：" prop="paymentAmount">
                <Input   v-model="addForm.paymentAmount" placeholder="请输入付款金额..."></Input>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="付款方式：" prop="paymentMethod">
                <Select v-model="addForm.paymentMethod" style="width:100%" placeholder="请选择付款方式...">
                  <Option value="网上银行">网上银行</Option>
                  <Option value="现金">现金</Option>
                  <Option value="转帐支票">转帐支票</Option>
                  <Option value="现金支票">现金支票</Option>
                  <Option value="银行汇票">银行汇票</Option>
                  <Option value="电汇">电汇</Option>
                  <Option value="承兑汇票">承兑汇票</Option>
                  <Option value="现金支票">现金支票</Option>
                </Select>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="银行：">
                <Select v-model="addForm.bank" style="width:100%" placeholder="请选择银行...">
                  <Option v-for="(item,key) in bankList" :key="key" :value="item.text">{{item.text}}</Option>
                </Select>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="银行账号：">
                <Input v-model="addForm.bankAccount" :minlength="15" :maxlength="19" placeholder="请输入银行账号..."></Input>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="汇率：">
                <Input v-model="addForm.exchangeRate" placeholder="请输入汇率..."></Input>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="所属项目：" prop="belongProject">
                <Input v-model="addForm.belongProject" placeholder="请输入所属项目..."></Input>
              </FormItem>
            </Col>
          </Row>
          <Row>
            <Col span="24">
              <FormItem label="摘要：" prop="summary">
                <Input type="textarea" :row="4" v-model="addForm.summary" placeholder="请输入摘要..."></Input>
              </FormItem>
            </Col>
          </Row>
        </Form>
        <div class="demo-drawer-footer">
          <Button type="primary" @click="handleSubmit2('addForm')">确认</Button>
          <Button @click="handleReset('addForm')" style="margin-left: 8px">取消</Button>
        </div>
      </Drawer>
    </div>
</template>

<script>
  import expandRow from './table-expand.vue';
  import {mapGetters, mapActions} from 'vuex';
  import {toGet,toPost} from "../../utils/MyAxios";
  export default {
    name: "receipt",
    components: { expandRow },
    data() {
      return {
        search:'',
        category:'全部',
        confirmStatus:'全部',
        beginTime:'',
        endTime:'',
        loading:false,
        addForm:{},
        addDrawer:false,
        updateDrawer:false,
        addRuleVal:{
          category: [
            { required: true, message: '请选择类型', trigger: 'blur' }
          ],
          receiptNumber: [
            { required: true, message: '请输入发票号', trigger: 'blur' }
          ],
          transitUnit: [
            { required: true, message: '请输入往来单位', trigger: 'blur' }
          ],
          paymentAmount: [
            { required: true, message: '请输入付款金额', trigger: 'blur' }
          ],
          paymentMethod: [
            { required: true, message: '请选择付款方式', trigger: 'blur' }
          ],
          belongProject: [
            { required: true, message: '请输入所属项目', trigger: 'blur' }
          ],
          summary: [
            { required: true, message: '请输入摘要', trigger: 'blur' }
          ],
        },
        tb_columns: [
          {
            type: 'expand',
            width: 50,
            render: (h, params) => {
              return h(expandRow, {
                props: {
                  row: params.row
                }
              })
            }
          },
          {
            title: '付款日期',
            key: 'paymentDate',
            align: 'center'
          },
          {
            title: '类型',
            key: 'category',
            align: 'center'
          },
          {
            title: '往来单位',
            key: 'transitUnit',
            align: 'center'
          },
          {
            title: '付款金额',
            key: 'paymentAmount',
            align: 'center'
          },
          {
            title: '付款方式',
            key: 'paymentMethod',
            align: 'center'
          },
          {
            title: '执行人',
            key: 'executive',
            align: 'center'
          },
          {
            title: '所属项目',
            key: 'belongProject',
            align: 'center'
          },
          {
            title: '摘要',
            key: 'summary',
            align: 'center'
          },
          {
            title: '确认状态',
            slot: 'confirmationStatus',
            align: 'center'
          },
          {
            title: '确认人',
            key: 'confirmationPeople',
            align: 'center'
          },
          {
            title: '操作',
            align: 'center',
            render: (h, params) => {
              if(params.row.confirmationStatus==='未确认'){
                return h('div', [
                  h('Button', {
                    props: {
                      icon: 'md-checkmark-circle-outline',
                      size: 'small'
                    },
                    style: {
                      color: 'black',
                    },
                    on: {
                      click: () => {
                        this.toUpdate(params.row.id)
                      }
                    }
                  }),
                  h('Button', {
                    props: {
                      icon: 'md-trash',
                      size: 'small'
                    },
                    style: {
                      color: 'black',
                    },
                    on: {
                      click: () => {
                        this.toDel(params.row.id)
                      }
                    }
                  })
                ]);
              }
            }
          }
        ],
        bankList:[
          {
            value:'CDB',
            text:'国家开发银行'
          },
          {
            value:'ICBC',
            text:'中国工商银行'
          },
          {
            value:'ABC',
            text:'中国农业银行'
          },
          {
            value:'BOC',
            text:'中国银行'
          },
          {
            value:'CCB',
            text:'中国建设银行'
          },
          {
            value:'PSBC',
            text:'中国邮政储蓄银行'
          },
          {
            value:'COMM',
            text:'交通银行'
          },
          {
            value:'CMB',
            text:'招商银行'
          },
          {
            value:'SPDB',
            text:'上海浦东发展银行'
          },
          {
            value:'CIB',
            text:'兴业银行'
          },
          {
            value:'HXBANK',
            text:'华夏银行'
          },
          {
            value:'GDB',
            text:'广东发展银行'
          },
          {
            value:'CMBC',
            text:'中国民生银行'
          },
          {
            value:'CITIC',
            text:'中信银行'
          },
          {
            value:'CEB',
            text:'中国光大银行'
          },
          {
            value:'EGBANK',
            text:'恒丰银行'
          },
          {
            value:'CZBANK',
            text:'浙商银行'
          },
          {
            value:'BOHAIB',
            text:'渤海银行'
          },
          {
            value:'SPABANK',
            text:'平安银行'
          },
          {
            value:'SHRCB',
            text:'上海农村商业银行'
          },
          {
            value:'YXCCB',
            text:'玉溪市商业银行'
          },
          {
            value:'YDRCB',
            text:'尧都农商行'
          },
          {
            value:'BJBANK',
            text:'北京银行'
          },
          {
            value:'SHBANK',
            text:'上海银行'
          },
          {
            value:'JSBANK',
            text:'江苏银行'
          },
          {
            value:'HZCB',
            text:'杭州银行'
          },
          {
            value:'NJCB',
            text:'南京银行'
          },
          {
            value:'NBBANK',
            text:'宁波银行'
          },
          {
            value:'HSBANK',
            text:'徽商银行'
          },
          {
            value:'CSCB',
            text:'长沙银行'
          },
          {
            value:'CDCB',
            text:'成都银行'
          },
          {
            value:'CQBANK',
            text:'重庆银行'
          },
          {
            value:'DLB',
            text:'大连银行'
          },
          {
            value:'NCB',
            text:'南昌银行'
          },
          {
            value:'FJHXBC',
            text:'福建海峡银行'
          },
          {
            value:'HKB',
            text:'汉口银行'
          },
          {
            value:'WZCB',
            text:'温州银行'
          },
          {
            value:'QDCCB',
            text:'青岛银行'
          },
          {
            value:'TZCB',
            text:'台州银行'
          },
          {
            value:'JXBANK',
            text:'嘉兴银行'
          },
          {
            value:'CSRCB',
            text:'常熟农村商业银行'
          },
          {
            value:'NHB',
            text:'南海农村信用联社'
          },
          {
            value:'CZRCB',
            text:'常州农村信用联社'
          },
          {
            value:'H3CB',
            text:'内蒙古银行'
          },
          {
            value:'SXCB',
            text:'绍兴银行'
          },
          {
            value:'SDEB',
            text:'顺德农商银行'
          },
          {
            value:'WJRCB',
            text:'吴江农商银行'
          },
          {
            value:'ZBCB',
            text:'齐商银行'
          },
          {
            value:'GYCB',
            text:'贵阳市商业银行'
          },
          {
            value:'ZYCBANK',
            text:'遵义市商业银行'
          },
          {
            value:'HZCCB',
            text:'湖州市商业银行'
          },
          {
            value:'DAQINGB',
            text:'龙江银行'
          },
          {
            value:'JINCHB',
            text:'晋城银行JCBANK'
          },
          {
            value:'ZJTLCB',
            text:'浙江泰隆商业银行'
          },
          {
            value:'GDRCC',
            text:'广东省农村信用社联合社'
          },
          {
            value:'DRCBCL',
            text:'东莞农村商业银行'
          },
          {
            value:'MTBANK',
            text:'浙江民泰商业银行'
          },
          {
            value:'GCB',
            text:'广州银行'
          },
          {
            value:'LYCB',
            text:'辽阳市商业银行'
          },
          {
            value:'JSRCU',
            text:'江苏省农村信用联合社'
          },
          {
            value:'LANGFB',
            text:'廊坊银行'
          },
          {
            value:'CZCB',
            text:'浙江稠州商业银行'
          },
          {
            value:'DYCB',
            text:'德阳商业银行'
          },
          {
            value:'JZBANK',
            text:'晋中市商业银行'
          },
          {
            value:'BOSZ',
            text:'苏州银行'
          },
          {
            value:'GLBANK',
            text:'桂林银行'
          },
          {
            value:'URMQCCB',
            text:'乌鲁木齐市商业银行'
          },
          {
            value:'CDRCB',
            text:'成都农商银行'
          },
          {
            value:'ZRCBANK',
            text:'张家港农村商业银行'
          },
          {
            value:'BOD',
            text:'东莞银行'
          },
          {
            value:'LSBANK',
            text:'莱商银行'
          },
          {
            value:'BJRCB',
            text:'北京农村商业银行'
          },
          {
            value:'TRCB',
            text:'天津农商银行'
          },
          {
            value:'SRBANK',
            text:'上饶银行'
          },
          {
            value:'FDB',
            text:'富滇银行'
          },
          {
            value:'CRCBANK',
            text:'重庆农村商业银行'
          },
          {
            value:'ASCB',
            text:'鞍山银行'
          },
          {
            value:'NXBANK',
            text:'宁夏银行'
          },
          {
            value:'BHB',
            text:'河北银行'
          },
          {
            value:'HRXJB',
            text:'华融湘江银行'
          },
          {
            value:'ZGCCB',
            text:'自贡市商业银行'
          },
          {
            value:'YNRCC',
            text:'云南省农村信用社'
          },
          {
            value:'JLBANK',
            text:'吉林银行'
          },
          {
            value:'DYCCB',
            text:'东营市商业银行'
          },
          {
            value:'KLB',
            text:'昆仑银行'
          },
          {
            value:'ORBANK',
            text:'鄂尔多斯银行'
          },
          {
            value:'XTB',
            text:'邢台银行'
          },
          {
            value:'JSB',
            text:'晋商银行'
          },
          {
            value:'TCCB',
            text:'天津银行'
          },
          {
            value:'BOYK',
            text:'营口银行'
          },
          {
            value:'JLRCU',
            text:'吉林农信'
          },
          {
            value:'SDRCU',
            text:'山东农信'
          },
          {
            value:'XABANK',
            text:'西安银行'
          },
          {
            value:'HBRCU',
            text:'河北省农村信用社'
          },
          {
            value:'NXRCU',
            text:'宁夏黄河农村商业银行'
          },
          {
            value:'GZRCU',
            text:'贵州省农村信用社'
          },
          {
            value:'FXCB',
            text:'阜新银行'
          },
          {
            value:'HBHSBANK',
            text:'湖北银行黄石分行'
          },
          {
            value:'ZJNX',
            text:'浙江省农村信用社联合社'
          },
          {
            value:'XXBANK',
            text:'新乡银行'
          },
          {
            value:'HBYCBANK',
            text:'湖北银行宜昌分行'
          },
          {
            value:'LSCCB',
            text:'乐山市商业银行'
          },
          {
            value:'TCRCB',
            text:'江苏太仓农村商业银行'
          },
          {
            value:'BZMD',
            text:'驻马店银行'
          },
          {
            value:'GZB',
            text:'赣州银行'
          },
          {
            value:'WRCB',
            text:'无锡农村商业银行'
          },
          {
            value:'BGB',
            text:'广西北部湾银行'
          },
          {
            value:'GRCB',
            text:'广州农商银行'
          },
          {
            value:'JRCB',
            text:'江苏江阴农村商业银行'
          },
          {
            value:'BOP',
            text:'平顶山银行'
          },
          {
            value:'TACCB',
            text:'泰安市商业银行'
          },
          {
            value:'CGNB',
            text:'南充市商业银行'
          },
          {
            value:'CCQTGB',
            text:'重庆三峡银行'
          },
          {
            value:'XLBANK',
            text:'中山小榄村镇银行'
          },
          {
            value:'HDBANK',
            text:'邯郸银行'
          },
          {
            value:'KORLABANK',
            text:'库尔勒市商业银行'
          },
          {
            value:'BOJZ',
            text:'锦州银行'
          },
          {
            value:'QLBANK',
            text:'齐鲁银行'
          },
          {
            value:'BOQH',
            text:'青海银行'
          },
          {
            value:'YQCCB',
            text:'阳泉银行'
          },
          {
            value:'SJBANK',
            text:'盛京银行'
          },
          {
            value:'FSCB',
            text:'抚顺银行'
          },
          {
            value:'ZZBANK',
            text:'郑州银行'
          },
          {
            value:'SRCB',
            text:'深圳农村商业银行'
          },
          {
            value:'BANKWF',
            text:'潍坊银行'
          },
          {
            value:'JJBANK',
            text:'九江银行'
          },
          {
            value:'JXRCU',
            text:'江西省农村信用'
          },
          {
            value:'HNRCU',
            text:'河南省农村信用'
          },
          {
            value:'GSRCU',
            text:'甘肃省农村信用'
          },
          {
            value:'SCRCU',
            text:'四川省农村信用'
          },
          {
            value:'GXRCU',
            text:'广西省农村信用'
          },
          {
            value:'SXRCCU',
            text:'陕西信合'
          },
          {
            value:'WHRCB',
            text:'武汉农村商业银行'
          },
          {
            value:'YBCCB',
            text:'宜宾市商业银行'
          },
          {
            value:'KSRB',
            text:'昆山农村商业银行'
          },
          {
            value:'SZSBK',
            text:'石嘴山银行'
          },
          {
            value:'HSBK',
            text:'衡水银行'
          },
          {
            value:'XYBANK',
            text:'信阳银行'
          },
          {
            value:'NBYZ',
            text:'鄞州银行'
          },
          {
            value:'ZJKCCB',
            text:'张家口市商业银行'
          },
          {
            value:'XCYH',
            text:'许昌银行'
          },
          {
            value:'JNBANK',
            text:'济宁银行'
          },
          {
            value:'CBKF',
            text:'开封市商业银行'
          },
          {
            value:'WHCCB',
            text:'威海市商业银行'
          },
          {
            value:'HBC',
            text:'湖北银行'
          },
          {
            value:'BOCD',
            text:'承德银行'
          },
          {
            value:'BODD',
            text:'丹东银行'
          },
          {
            value:'JHBANK',
            text:'金华银行'
          },
          {
            value:'BOCY',
            text:'朝阳银行'
          },
          {
            value:'LSBC',
            text:'临商银行'
          },
          {
            value:'BSB',
            text:'包商银行'
          },
          {
            value:'LZYH',
            text:'兰州银行'
          },
          {
            value:'BOZK',
            text:'周口银行'
          },
          {
            value:'DZBANK',
            text:'德州银行'
          },
          {
            value:'SCCB',
            text:'三门峡银行'
          },
          {
            value:'AYCB',
            text:'安阳银行'
          },
          {
            value:'ARCU',
            text:'安徽省农村信用社'
          },
          {
            value:'HURCB',
            text:'湖北省农村信用社'
          },
          {
            value:'HNRCC',
            text:'湖南省农村信用社'
          },
          {
            value:'NYNB',
            text:'广东南粤银行'
          },
          {
            value:'LYBANK',
            text:'洛阳银行'
          },
          {
            value:'NHQS',
            text:'农信银清算中心'
          },
          {
            value:'CBBQS',
            text:'城市商业银行资金清算中心'
          }
        ],
      }
    },
    computed: {
      ...mapGetters(['receipt_list','receipt_total','receipt_current_page','receipt_page_size']),
    },
    methods: {
      ...mapActions(['getReceiptList']),
      handleSubmit (name) {
        this.$refs[name].validate((valid) => {
          if (valid) {
            if(this.addForm.paymentDate){
              this.loading=true;
              let date = new Date(this.addForm.paymentDate);
              this.addForm.paymentDate=date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
              let params = {
                category:this.addForm.category,
                paymentDate:this.addForm.paymentDate,
                receiptNumber:this.addForm.receiptNumber,
                transitUnit:this.addForm.transitUnit,
                paymentAmount:this.addForm.paymentAmount,
                paymentMethod:this.addForm.paymentMethod,
                bank:this.addForm.bank,
                bankAccount:this.addForm.bankAccount,
                exchangeRate:this.addForm.exchangeRate,
                belongProject:this.addForm.belongProject,
                summary:this.addForm.summary,
                executive:localStorage.getItem('nickname'),
              };
              toPost('/finance-management/finance/receipt/add',params)
                .then(res=>{
                  if (res.resultCode === 0) {
                    this.$Notice.success({
                      title: '新增成功'
                    });
                    this.$refs[name].resetFields();
                    this.toRefresh();
                    this.addDrawer=false;
                  }else{
                    this.$Notice.error({
                      title: '新增失败',
                      desc: '服务器发生未知错误'
                    })
                  }
                });
              this.loading=false;
            }else{
              this.$Notice.warning({
                title: '请填写日期',
              })
            }

          }
        })
      },
      handleSubmit2 (name) {
        this.$refs[name].validate((valid) => {
          if (valid) {
            this.loading=true;
            if(this.addForm.paymentDate){
              swal({
                title: "您确认吗？",
                text:'确认后将无法修改，且无法删除',
                icon: "info",
                buttons: ["取消", "确认"],
              })
                .then((willDown) => {
                  if (willDown) {
                    let date = new Date(this.addForm.paymentDate);
                    this.addForm.paymentDate=date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
                    let params = {
                      id:this.addForm.id,
                      category:this.addForm.category,
                      paymentDate:this.addForm.paymentDate,
                      receiptNumber:this.addForm.receiptNumber,
                      transitUnit:this.addForm.transitUnit,
                      paymentAmount:this.addForm.paymentAmount,
                      paymentMethod:this.addForm.paymentMethod,
                      bank:this.addForm.bank,
                      bankAccount:this.addForm.bankAccount,
                      exchangeRate:this.addForm.exchangeRate,
                      belongProject:this.addForm.belongProject,
                      summary:this.addForm.summary,
                      confirmationStatus:'已确认',
                      confirmationPeopleId:localStorage.getItem('userId'),
                      confirmationPeople:localStorage.getItem('nickname'),
                    };
                    toPost('/finance-management/finance/receipt/confirm',params)
                      .then(res=>{
                        if (res.resultCode === 0) {
                          this.$Notice.success({
                            title: '修改成功'
                          });
                          this.$refs[name].resetFields();
                          this.toRefresh();
                          this.updateDrawer=false;
                        }else{
                          this.$Notice.error({
                            title: '修改失败',
                            desc: '服务器发生未知错误'
                          })
                        }
                      });
                    this.loading=false;
                  }
                });
            }else{
              this.$Notice.warning({
                title: '请填写日期',
              })
            }
          }
        })
      },
      handleReset (name) {
        this.addDrawer=false;
        this.addForm={};
        this.updateDrawer=false;
        this.$refs[name].resetFields();
      },
      onChange(currentPage){
        this.getReceiptList({
          'search':this.search,
          'category':this.category,
          'confirmStatus':this.confirmStatus,
          'beginTime':this.formatDate(this.beginTime),
          'endTime':this.formatDate(this.endTime),
          'currentPage':currentPage*1,
          'pageSize':this.receipt_page_size
        });
      },
      toRefresh(){
        this.getReceiptList({
          'search':this.search,
          'category':this.category,
          'confirmStatus':this.confirmStatus,
          'beginTime':this.formatDate(this.beginTime),
          'endTime':this.formatDate(this.endTime),
          'currentPage':this.receipt_current_page,
          'pageSize':this.receipt_page_size
        });
      },
      jump(e){
        this.$router.push(e);
      },
      toUpdate(id){
        toGet('/finance-management/finance/receipt/queryOne/'+id)
          .then(res=>{
            if (res.resultCode === 0) {
              this.addForm=res.data;
              this.updateDrawer=true;
            }else{
              this.$Notice.warning({
                title: '获取信息失败',
                desc: '服务器发生未知错误'
              });
            }
          });
      },
      toDel(id){
        swal({
          title: "您确定删除该条记录吗?",
          text: "删除该条记录后，系统将删除该条记录的所有信息!",
          icon: "warning",
          buttons: ["容我再想想!", "确认删除!"],
          dangerMode: true,
        })
          .then((willDelete) => {
            if (willDelete) {
              toGet('/finance-management/finance/receipt/delete/'+id)
                .then(res=>{
                  if (res.resultCode === 0) {
                    swal("删除成功!", {
                      icon: "success",
                    });
                    this.toRefresh();
                  }
                })
                .catch(error=>{
                  swal("删除失败!", {
                    icon: "error",
                  });
                });
            }
          });
      },
      onPageSizeChange(pageSize){
        this.getReceiptList({
          'search':this.search,
          'category':this.category,
          'confirmStatus':this.confirmStatus,
          'beginTime':this.formatDate(this.beginTime),
          'endTime':this.formatDate(this.endTime),
          'currentPage':this.receipt_current_page,
          'pageSize':pageSize*1
        });
      },
      toSearch(){
        this.getReceiptList({
          'search':this.search,
          'category':this.category,
          'confirmStatus':this.confirmStatus,
          'beginTime':this.formatDate(this.beginTime),
          'endTime':this.formatDate(this.endTime),
          'currentPage':this.receipt_current_page,
          'pageSize':this.receipt_page_size
        });
      },
      formatDate(date){
        if(date){
          let time = new Date(date);
          return time.getFullYear() + '-' + (time.getMonth() + 1) + '-' + time.getDate();
        }else{
          return '';
        }
      }
    },
    mounted() {
      this.getReceiptList({
        'search':this.search,
        'category':this.category,
        'confirmStatus':this.confirmStatus,
        'beginTime':this.formatDate(this.beginTime),
        'endTime':this.formatDate(this.endTime),
        'currentPage':1,
        'pageSize':10
      });
    },
  }
</script>

<style lang="css" scoped>
  .demo-drawer-footer{
    width: 100%;
    position: absolute;
    bottom: 0;
    left: 0;
    border-top: 1px solid #e8e8e8;
    padding: 10px 16px;
    text-align: right;
    background: #fff;
  }
</style>
